home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_138 / modulatools / modulatools.source / fonttools.def < prev    next >
Text File  |  1992-05-06  |  7KB  |  115 lines

  1. (******************************************************************************)
  2. (*                                                                            *)
  3. (*    The global constants and variables defined in this module are optional: *)
  4. (* if you don't want to access their features, you needn't import them into   *)
  5. (* your program. The variables in the parameter lists of the procedures are   *)
  6. (* the only variables you are required to supply.                             *)
  7. (*    When describing the order in which certain routines are called, I have  *)
  8. (* adopted the curly-bracket notation of EBNF: routines in curly brackets {}  *)
  9. (* may be called an arbitrary number of times (0 to n). A, {B}, {C, {D}} thus *)
  10. (* implies that A is called once, followed by an arbitrary number of calls to *)
  11. (* to B, followed by an arbitrary number of calls to C. Each of the calls to  *)
  12. (* C may be followed by an arbitrary number of calls to D. Likewise, {{C},{D}}*)
  13. (* implies an arbitrary number of calls to C and D in any order.              *)
  14. (*                                                                            *)
  15. (******************************************************************************)
  16. (*                                                                            *)
  17. (*  Version 1.00a.002 (Beta) :   March 2, 1988                                *)
  18. (*                                                                            *)
  19. (*    These procedures were originally written under version 1.20 of the TDI  *)
  20. (* Modula-2 compiler. I have rewritten this module to operate under the v2.00 *)
  21. (* compiler. However, should you find any problem or inconsistency with the   *)
  22. (* functionality of this code, please contact me at the following address:    *)
  23. (*                                                                            *)
  24. (*                               Jerry Mack                                   *)
  25. (*                               23 Prospect Hill Ave.                        *)
  26. (*                               Waltham, MA   02154                          *)
  27. (*                                                                            *)
  28. (*    Check the module MenuUtils for TDI's (considerably less powerful) ver-  *)
  29. (* sions of my Menu and IntuitionText procedures. The modules GadgetUtils and *)
  30. (* EasyGadgets should also be of great help.                                  *)
  31. (*                                                                            *)
  32. (******************************************************************************)
  33. (*                                                                            *)
  34. (*    The source code to FontTools is in the public domain. You may do with   *)
  35. (* it as you please.                                                          *)
  36. (*                                                                            *)
  37. (******************************************************************************)
  38.  
  39. DEFINITION MODULE FontTools;
  40.  
  41. FROM DiskFontLibrary IMPORT AvailFontsHeaderPtr;
  42. FROM Libraries       IMPORT LibraryPtr;
  43. FROM Text            IMPORT TextFontPtr;
  44.  
  45. TYPE
  46.    FontListNodePtr  = POINTER TO FontListNodeType;
  47.    FontListNodeType = RECORD
  48.                        node : TextFontPtr;
  49.                        next : FontListNodePtr;
  50.                       END; (* FontListNodeType *)
  51.  
  52. VAR
  53.    UserDiskFontBase  : LibraryPtr;       (* entry point into DiskFont library *)
  54.    FontBuffer        : AvailFontsHeaderPtr; (* description of available fonts *)
  55.    FontList          : FontListNodePtr;   (* list of pointers to opened fonts *)
  56.  
  57.  
  58.    PROCEDURE GetAndSortAllFonts () : BOOLEAN;
  59.  
  60.    PROCEDURE ReturnFontResourcesToSystem;
  61.  
  62.    PROCEDURE OpenAllFonts () : CARDINAL;
  63.    
  64.    PROCEDURE CloseAllFonts;
  65.  
  66.  
  67.  (* GetAndSortAllFonts fills FontBuffer with an array of AvailFonts struc-   *)
  68.  (* tures, each of which contains a TextAttr structure and a flag informing  *)
  69.  (* whether the font resides in memory or on disk. The array contains data   *)
  70.  (* for the system fonts and all fonts in the FONTS: directory. The array is *)
  71.  (* sorted by name and also by point-size. Thus, the fonts on the left would *)
  72.  (* be returned in the order shown on the right:                             *)
  73.  (*                                                                          *)
  74.  (*   9 point  diamond.font                   9 point  diamond.font          *)
  75.  (*  12 point  ruby.font                      9 point  garnet.font           *)
  76.  (*   8 point  topaz.font                    16 point  garnet.font           *)
  77.  (*   9 point  topaz.font                    12 point  ruby.font             *)
  78.  (*  19 point  sapphire.font                 19 point  sapphire.font         *)
  79.  (*  11 point  topaz.font                     8 point  topaz.font            *)
  80.  (*   9 point  garnet.font                    9 point  topaz.font            *)
  81.  (*  16 point  garnet.font                   11 point  topaz.font            *)
  82.  (*                                                                          *)
  83.  
  84.  (* ReturnFontResourcesToSystem should be called when you are finished with  *)
  85.  (* the FontBuffer. Also, you must call ReturnFontResourcesToSystem prior to *)
  86.  (* calling GetAndSortAllFonts again. However, unless you reassign the FONTS:*)
  87.  (* directory, there is little need to call GetAndSortAllFonts more than     *)
  88.  (* once. ReturnFontResourcesToSystem closes the DiskFont library which Get- *)
  89.  (* AndSortAllFonts opened (and which you may access via UserDiskFontBase),  *)
  90.  (* and DEALLOCATES the memory used by FontBuffer.                           *)
  91.  
  92.  
  93.  (* OpenAllFonts opens all of the fonts in the FONTS: directory, making them *)
  94.  (* immediately available for use in your program. OpenAllFonts first calls  *)
  95.  (* GetAndSortAllFonts to obtain a list of the fonts available. It then opens*)
  96.  (* each font (in the order listed in FontBuffer) and adds a pointer to the  *)
  97.  (* corresponding font-definition structure to the global variable FontList. *)
  98.  (* In the process of opening it, the font is added to the system font-list, *)
  99.  (* where it remains until it is closed and removed by each of the processes *)
  100.  (* which opened it. OpenAllFonts returns the number of fonts it opened.     *)
  101.  
  102.  (* CloseAllFonts closes all of the fonts listed in FontList and relinquishes*)
  103.  (* all memory used by the FontList. Furthermore, it also removes each font  *)
  104.  (* from the system font-list, unless another task is using the font. Lastly,*)
  105.  (* CloseAllFonts calls ReturnFontResourcesToSystem to relinquish the memory *)
  106.  (* used by FontBuffer and everything else described above.                  *)
  107.  
  108.  (* The order in which these procedures are invoked is as follows:           *)
  109.  (*                                                                          *)
  110.  (*      { {GetAndSortAllFonts, ReturnFontResourcesToSystem},                *)
  111.  (*                                                                          *)
  112.  (*        {OpenAllFonts,       CloseAllFonts              } }               *)
  113.  
  114. END FontTools.
  115.